package com.jsbj.user.controller;


import com.alibaba.fastjson.JSONObject;
import com.jsbj.base.ResultBean;
import com.jsbj.framework.controller.BaseController;
import com.jsbj.user.entities.SysPermissionAll;
import com.jsbj.user.service.ISysPermissionAllService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 系统菜单-页面-按钮表 前端控制器
 * </p>
 *
 * @author jsbj
 * @since 2022-03-07
 */
@RestController
@RequestMapping("/sys-permission-all")
@Api(value = "业务系统菜单配置", tags = "业务系统菜单配置")
@ApiIgnore
public class SysPermissionAllController extends BaseController {

    @Autowired
    private ISysPermissionAllService sysPermissionAllService;

    @ApiOperation("查询列表")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功", response = SysPermissionAll.class)})
    @PostMapping("getListData")
    public ResultBean<List<SysPermissionAll>> getListData(@RequestBody String inParam){
        return new ResultBean<List<SysPermissionAll>>(sysPermissionAllService.getListData(inParam));
    }

    @ApiOperation("新增或编辑保存")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @PostMapping("saveOrUpdateData")
    public ResultBean<JSONObject> saveOrUpdateData(@RequestBody SysPermissionAll sysPermissionAll){
        return sysPermissionAllService.saveOrUpdateData(sysPermissionAll);
    }

    @ApiOperation("查看详情")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "id", value = "id（行）", required = true)}
    )
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功", response = SysPermissionAll.class)})
    @PostMapping("getDetail")
    public ResultBean<SysPermissionAll> getDetail(@RequestParam String id){
        return new ResultBean<SysPermissionAll>(sysPermissionAllService.getDetail(id));
    }

    @ApiOperation("删除数据")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "id", value = "id（行）", required = true)}
    )
    @PostMapping("deleteData")
    public ResultBean<JSONObject> deleteData(@RequestParam String id){
        return sysPermissionAllService.deleteData(id);
    }

}

